package com.ccit.springbootlaw.pojo;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Table(name = "comments") // 显式指定表名
// 评论表
// id (主键)
// content (评论内容)
// user_id (用户ID)
// article_id (文章ID)
// parent_id (父评论ID)
// created_at (创建时间)
public class Comment {
    private int id;
    private String content;
    private int userId;
    private int articleId;
    private Integer parentId;
    private Timestamp created_at;

    @Id
    @Column(name = "id")
    // id (主键)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "content")
    // content (评论内容)
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Basic
    @Column(name = "user_id")
    // user_id (用户ID)
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "article_id")
    // article_id (文章ID)
    public int getArticleId() {
        return articleId;
    }

    public void setArticleId(int articleId) {
        this.articleId = articleId;
    }

    @Basic
    @Column(name = "parent_id")
    // parent_id (父评论ID)
    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    @Basic
    @Column(name = "created_at")
    // created_at (创建时间)
    public Timestamp getCreatedAt() {
        return created_at;
    }

    public void setCreatedAt(Timestamp createdAt) {
        this.created_at = createdAt;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Comment comments = (Comment) o;
        return id == comments.id && userId == comments.userId && articleId == comments.articleId && Objects.equals(content, comments.content) && Objects.equals(parentId, comments.parentId) && Objects.equals(created_at, comments.created_at);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, content, userId, articleId, parentId, created_at);
    }
}